const axios = require('axios')
// const Vue = require('vue')
const { Message } = require('element-ui');
const router = require('../../router/index');

module.exports = {
    namespaced: true,
    state: {
        admData: [],
    },
    mutations: {
        getadmCart(state, data) {
            state.admData = data
        },
    },
    actions: {
        async getadmAsync(context, searchData) {
            let fy = {
                ...searchData,
            }
            console.info(fy)
            const { data } = await axios.get("/adm/getAdm", { params: fy });
            //使用mutations函数
            const adm = data
            console.info(data)
            context.commit('getadmCart', [...adm]);
        },

        async deleteAdm(context, _id) {
            const { data } = await axios.post("/adm/removeAdm", { _id });
            // console.log(data);
            context.dispatch('getadmAsync')
        },
        async updataAdm(context, row) {
            const { data } = await axios.post("/adm/uptateAdm", row);
            // console.log(data);
            context.dispatch('getadmAsync')
        },

    }

}